<template>
	<view>
		<web-view :src="webViewSrc"></web-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				payOrder: {},
				payType: 0,
				webViewSrc: ''
			}
		},
		onLoad(options) {
			this.payOrder = JSON.parse(options.payOrder);
			this.payType = options.payType;
			uni.setNavigationBarTitle({
				title: "支付"
			})
			uni.setNavigationBarColor({
				frontColor: '#ffffff',
				backgroundColor: '#e74c3c'
			});
			if (this.payType == 1) {
				this.toWechatPay();
			} else {
				this.toAlipay();
			}
		},
		methods: {
			toAlipay() {
				this.webViewSrc = this.$baseConfig.APIHOST + "/" + this.$Api.aliPayH5 +
					"?orderNo=" + this.payOrder.orderNo;
				console.log(this.webViewSrc)
				setTimeout(() => {
					this.webViewSrc = "";
				}, 10000);
				//this.checkPay();
			},
			toWechatPay() {
				this.$Request.postFormHost(this.$Api.wxPayHtml).then(res => {
					if (res.status === 0) {
						this.webViewSrc = res.data + "?orderNo=" + this.payOrder.orderNo;
						//this.checkPay();
					} else {
						uni.showToast({
							icon: "none",
							title: res.msg
						});
					}
				});

			}
		}
	}
</script>

<style>

</style>